<template>
	<!-- 人脉资源 -->
	<view class="rmzy-list">
		<view class="row" v-for="(rmzy, index) in rmzyData" :key="index">
			<view class="row-top">
				<view class="left">
					<view class="head" @click="toPage(rmzy)">
						<image class="profilephoto" :src="rmzy.member?rmzy.member.avatar:rmzy.avatar" mode="widthFix">
						</image>
						<!-- VIP -->
						<image class="vip" v-if="rmzy.member.authStatus == '1' || rmzy.member.authStatus == '2' || rmzy.authStatus == '1' || rmzy.authStatus == '2'"
							src="https://luntan.xiaouyf.cn/uecs-wechat/static/img/qianduan/home_vip.png"
							mode="widthFix"></image>
					</view>
				</view>
				<view class="right">
					<view class="right-row-between">
						<!-- 姓名 -->
						<view class="name">{{ rmzy.member.realName || rmzy.realName }}</view>
						<!-- 认证 -->
						<view class="authenticated" v-if="rmzy.srStatus == '1'">
							<image src="https://luntan.xiaouyf.cn/uecs-wechat/static/img/qianduan/home_yrz.png"
								mode="widthFix"></image>
							<text>已实名</text>
						</view>
					</view>
					<view v-if="rmzy.companyName" class="right-row">
						<!-- 公司 -->
						<view class="company">{{ rmzy.companyName || '-' }}</view>
						<!-- 职位 -->
						<view class="company">{{ rmzy.userPosition || '-' }}</view>
					</view>
				</view>
			</view>
			<view class="row-bottom">
				<view class="row-addres">
					<image src="https://luntan.xiaouyf.cn/uecs-wechat/static/img/qianduan/address_black.png"
						mode="widthFix" class="address_black"></image>
					<text class="row-addres-text"><text
							v-if="rmzy.city === '市辖区'">{{ rmzy.province || rmzy.member.province }}</text>{{ rmzy.city || '-' }}</text>
					<text class="row-addres-text">从业{{ rmzy.workYear || '-' }}</text>
					<text class="row-addres-text">有超过{{ rmzy.lookNumber || rmzy.lookNum }}人预览</text>
				</view>
				<view class="hxyw">
					<view class="hxyw-left">核心业务</view>
					<view class="hxyw-right">
						<view class="hxyw-block"
							v-for="(hxyw, index) in (rmzy.userScope && rmzy.userScope.length ? rmzy.userScope : ['-'])"
							:key="index">{{ hxyw }}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "Rmzy",
		data() {
			return {

			};
		},
		props: {
			rmzyData: {
				type: Array,
				default: () => []
			},
			mgGroup: {
				type: Boolean,
				default: false
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.user.userInfo;
			}
		},
		methods: {
			toPage(item) {
				// 检查登录状态
				if (!this.$store.state.user.isLoggedIn) {
					uni.showToast({
						title: '请先登录',
						icon: 'none'
					});
					// 跳转到登录页面
					setTimeout(() => {
						uni.redirectTo({
							url: '/pages/login/login'
						});
					}, 1500);
					return;
				}
				
				// 检查实名认证状态
				if (this.userInfo.srStatus !== '1' && this.userInfo.guid !== item.guid) {
					uni.showToast({
						title: '认证完成后才能查看用户信息',
						icon: 'none'
					});
					return;
				}
				// 如果是团队成员，跳转到我的名片
				if(this.mgGroup){
					uni.navigateTo({
						url: `/pages/my-card/my-card?id=${item.groupUserId}`
					})
				} else { 
					uni.navigateTo({
						url: `/pages/my-card/my-card?id=${item.guid}`
					})
				}
			}
		}
	}
</script>

<style lang="less">
	// 人脉资源列表
	.rmzy-list {
		margin-top: 20rpx;
		padding: 0 30rpx;

		.row {
			position: relative;
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;

			.row-top {
				display: flex;
				align-items: center;

				.left {
					display: flex;
					flex-direction: column;
					margin-right: 40rpx;
					flex-shrink: 0;

					.head {
						position: relative;
						// 头像

						.profilephoto {
							width: 100rpx;
							height: 100rpx;
							border: 2rpx solid #D8A561;
							border-radius: 100%;
						}

						.vip {
							width: 38rpx;
							height: 31rpx;
							position: absolute;
							right: -10rpx;
							top: 4rpx;
						}
					}

				}

				.right {
					position: relative;
					flex: 1;
					display: flex;
					flex-direction: column;

					.right-row-between {
						display: flex;
						justify-content: space-between;

						// 姓名
						.name {
							font-size: 36rpx;
							margin-bottom: 18rpx;
							font-weight: bold;
						}

						// 认证
						.authenticated {
							display: flex;
							align-items: center;
							font-size: 24rpx;
							color: #AC6C17;

							image {
								width: 21rpx;
								height: 24rpx;
								margin-right: 6rpx;
							}
						}
					}

					.right-row {
						display: flex;

						//  公司。职位
						.company {
							display: inline-block;
							font-size: 28rpx;
							margin-bottom: 18rpx;
							background: #FFEFD9;
							border-radius: 10rpx 10rpx 10rpx 10rpx;
							padding: 8rpx 15rpx;
							margin-right: 12rpx;
							color: #AC6C17;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							box-sizing: border-box;

							&:first-child {
								max-width: 300rpx;
							}
						}
					}
				}
			}

			.row-bottom {
				display: flex;
				flex-direction: column;
				margin-top: 25rpx;

				// 地址
				.row-addres {
					display: flex;
					align-items: center;
					margin-bottom: 25rpx;
					color: #333;
					font-size: 28rpx;

					.address_black {
						width: 19.89rpx;
						height: 24.04rpx;
						margin-right: 8rpx;
					}

					.row-addres-text {
						position: relative;
						padding-right: 10rpx;
						margin-right: 10rpx;

						&:after {
							content: '';
							position: absolute;
							right: 0;
							top: 51%;
							transform: translateY(-50%);
							width: 1rpx;
							height: 20rpx;
							background: #333;
						}

						&:last-child {
							&:after {
								display: none;
							}
						}

					}
				}

				// 核心业务
				.hxyw {
					display: flex;
					margin-bottom: 8rpx;

					.hxyw-left {
						position: relative;
						top: 4rpx;
						font-size: 28rpx;
						color: #333;
						margin-right: 20rpx;
					}

					.hxyw-right {
						display: flex;
						flex: 1;
						flex-wrap: wrap;

						.hxyw-block {
							min-width: 125rpx;
							text-align: center;
							font-size: 28rpx;
							background: #FFEFD9;
							padding: 10rpx 20rpx;
							box-sizing: border-box;
							border-radius: 4rpx;
							margin-right: 20rpx;
							margin-bottom: 20rpx;
							color: #AC6C17;
						}
					}
				}

				// 简介
				.introduction {
					font-size: 26rpx;
					color: #666;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					text-overflow: ellipsis;
				}
			}
		}
	}
</style>